<!--

    Copyright © 2016-2025 The Thingsboard Authors

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<div class="tb-login-content mat-app-background tb-dark flex flex-1 items-center justify-center">
  <mat-card appearance="raised" style="max-height: 80vh; overflow-y: auto;">
    <mat-card-content>
      <form class="tb-login-form" [formGroup]="loginFormGroup" (ngSubmit)="login()">
        <fieldset class="flex flex-col">
          <div class="flex flex-col items-center" style="padding: 15px 0;">
            <tb-logo class="login-logo"></tb-logo>
          </div>
          @if (isLoading$ | async) {
            <mat-progress-bar color="warn" mode="indeterminate">
            </mat-progress-bar>
          }
          @if (!(isLoading$ | async)) {
            <span style="height: 4px;"></span>
          }
          <div tb-toast class="layout-padding flex flex-col">
            <mat-divider style="width: 100%;"></mat-divider>
            <mat-form-field class="tb-appearance-transparent">
              <mat-label translate>login.username</mat-label>
              <input id="username-input" matInput type="email" autofocus formControlName="username" email required/>
              <mat-icon matPrefix>email</mat-icon>
              <mat-icon matSuffix
                        matTooltipClass="tb-error-tooltip"
                        matTooltip="{{ 'user.invalid-email-format' | translate }}"
                        [class.!hidden]="!(loginFormGroup.get('username').invalid && loginFormGroup.get('username').touched)"
                        class="tb-error">
                warning
              </mat-icon>
            </mat-form-field>
            <mat-form-field class="tb-appearance-transparent">
              <mat-label translate>common.password</mat-label>
              <input id="password-input" matInput type="password" formControlName="password"/>
              <tb-toggle-password matSuffix></tb-toggle-password>
              <mat-icon matPrefix>lock</mat-icon>
            </mat-form-field>
            <div class="forgot-password flex flex-row items-center justify-end">
              <button class="tb-reset-password" mat-button type="button" routerLink="/login/resetPasswordRequest">{{ 'login.forgot-password' | translate }}
              </button>
            </div>
            <div class="tb-action-button flex flex-col">
              <button mat-raised-button color="accent" [disabled]="(isLoading$ | async)"
              type="submit">{{ 'login.login' | translate }}</button>
            </div>
          </div>
        </fieldset>
      </form>
    </mat-card-content>
  </mat-card>
  <tb-footer></tb-footer>
</div>
